package com.lingyu.jsjx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.lingyu.jsjx.domain.ParttimeRecord;
import com.lingyu.jsjx.service.IParttimeRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 兼职任职档案Controller
 * 
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/parttimeRecord")
public class ParttimeRecordController extends BaseController
{
    @Autowired
    private IParttimeRecordService parttimeRecordService;

    /**
     * 查询兼职任职档案列表
     */
    @RequiresPermissions("jsjx:parttimeRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(ParttimeRecord parttimeRecord)
    {
        startPage();
        List<ParttimeRecord> list = parttimeRecordService.selectParttimeRecordList(parttimeRecord);
        return getDataTable(list);
    }

    /**
     * 导出兼职任职档案列表
     */
    @RequiresPermissions("jsjx:parttimeRecord:export")
    @Log(title = "兼职任职档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParttimeRecord parttimeRecord)
    {
        List<ParttimeRecord> list = parttimeRecordService.selectParttimeRecordList(parttimeRecord);
        ExcelUtil<ParttimeRecord> util = new ExcelUtil<ParttimeRecord>(ParttimeRecord.class);
        util.exportExcel(response, list, "兼职任职档案数据");
    }

    /**
     * 获取兼职任职档案详细信息
     */
    @RequiresPermissions("jsjx:parttimeRecord:query")
    @GetMapping(value = "/{parttimeId}")
    public AjaxResult getInfo(@PathVariable("parttimeId") Long parttimeId)
    {
        return success(parttimeRecordService.selectParttimeRecordByParttimeId(parttimeId));
    }

    /**
     * 新增兼职任职档案
     */
    @RequiresPermissions("jsjx:parttimeRecord:add")
    @Log(title = "兼职任职档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParttimeRecord parttimeRecord)
    {
        return toAjax(parttimeRecordService.insertParttimeRecord(parttimeRecord));
    }

    /**
     * 修改兼职任职档案
     */
    @RequiresPermissions("jsjx:parttimeRecord:edit")
    @Log(title = "兼职任职档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParttimeRecord parttimeRecord)
    {
        return toAjax(parttimeRecordService.updateParttimeRecord(parttimeRecord));
    }

    /**
     * 删除兼职任职档案
     */
    @RequiresPermissions("jsjx:parttimeRecord:remove")
    @Log(title = "兼职任职档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parttimeIds}")
    public AjaxResult remove(@PathVariable Long[] parttimeIds)
    {
        return toAjax(parttimeRecordService.deleteParttimeRecordByParttimeIds(parttimeIds));
    }
}
